/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.uq.comp7705.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author javierpanchi
 */
@Entity
@Table(name = "drk_session")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Session.findAll", query = "SELECT s FROM Session s"),
    @NamedQuery(name = "Session.findById", query = "SELECT s FROM Session s WHERE s.id = :id"),
    @NamedQuery(name = "Session.findBySince", query = "SELECT s FROM Session s WHERE s.since = :since"),
    @NamedQuery(name = "Session.findByDescription", query = "SELECT s FROM Session s WHERE s.description = :description"),
    @NamedQuery(name = "Session.findByFacebookid", query = "SELECT s FROM Session s WHERE s.facebookid = :facebookid and s.closed=0"),
    @NamedQuery(name = "Session.findByPlace", query = "SELECT s FROM Session s WHERE s.place = :place  and s.closed=0")})
public class Session implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "since")
    @Temporal(TemporalType.TIMESTAMP)
    private Date since;
    @Column(name = "description")
    private String description;
    @Column(name = "facebookid")
    private String facebookid;
    @Column(name = "facebook")
    private String nameFacebook;
    @Column(name = "place")
    private String place;
    @Column(name = "closed")
    private Integer closed;
    @JoinColumn(name = "drk_person_id", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Person drkPersonId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "drkSessionId", fetch = FetchType.LAZY)
    private List<SessionDrink> sessionDrinkList;

    public Session() {
    }

    public Session(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getSince() {
        return since;
    }

    public void setSince(Date since) {
        this.since = since;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getFacebookid() {
        return facebookid;
    }

    public void setFacebookid(String facebookid) {
        this.facebookid = facebookid;
    }

    public String getNameFacebook() {
        return nameFacebook;
    }

    public void setNameFacebook(String nameFacebook) {
        this.nameFacebook = nameFacebook;
    }

    
    
    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }

    public Integer getClosed() {
        return closed;
    }

    public void setClosed(Integer close) {
        this.closed = close;
    }
    
    

    public Person getDrkPersonId() {
        return drkPersonId;
    }

    public void setDrkPersonId(Person drkPersonId) {
        this.drkPersonId = drkPersonId;
    }

    @XmlTransient
    public List<SessionDrink> getSessionDrinkList() {
        return sessionDrinkList;
    }

    public void setSessionDrinkList(List<SessionDrink> sessionDrinkList) {
        this.sessionDrinkList = sessionDrinkList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Session)) {
            return false;
        }
        Session other = (Session) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.uq.comp7705.entity.Session[ id=" + id + " ]";
    }
    
}
